package com.san.bigSc.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.san.bigSc.service.BigScService;

@CacheConfig(cacheNames = { "myCache" })
@Service
public class BigScServiceImpl implements BigScService {

	@Override
	@Cacheable(key = "methodName")
	public Map<String, Object> queryCorporateCreditInformationStatistics() {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("totalCount", 13568); // 信息总量
		map.put("goodInformation", 1890); // 良好信息
		map.put("badInformation", 2678); // 不良信息
		map.put("other", 10090); // 其他
		map.put("newlyIncreased", 464565); // 本周新增
		return map;
	}

	@Override
	@Cacheable(key = "methodName")
	public Map<String, Object> queryEnterpriseQuantityStatistics() {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("totalCount", 24176); // 企业总量
		map.put("enterpriseWithDomesticFunding", 4680); // 内资企业
		map.put("nationalizedBusiness", 3579); // 国有企业
		map.put("collectivelyOwnedEnterprise", 23019); // 集体企业
		map.put("newlyIncreasedCount", 564578); // 本周新增
		return map;
	}

	@Override
	@Cacheable(key = "methodName")
	public Map<String, Object> queryApplicationDistribution() {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("score", 68); // 分数查询
		map.put("verification", 32); // 核查使用
		map.put("recording", 29); // 记录查询
		map.put("detection", 30); // 检测使用
		return map;
	}

	@Override
	@Cacheable(key = "methodName")
	public Map<String, Object> queryIndustryDistributionQuantity() {
		Map<String, Object> resultMap = new HashMap<String, Object>();

		Map<String, Object> tempMap = new HashMap<String, Object>();

		// 插入产业分布数据
		List<Map<String, Object>> cyfbList = new ArrayList<Map<String, Object>>();
		tempMap.put("name", "产业A");
		tempMap.put("num", 678);
		cyfbList.add(tempMap);
		tempMap = new HashMap<String, Object>();

		tempMap.put("name", "产业B");
		tempMap.put("num", 891);
		cyfbList.add(tempMap);
		tempMap = new HashMap<String, Object>();

		tempMap.put("name", "产业C");
		tempMap.put("num", 467);
		cyfbList.add(tempMap);
		tempMap = new HashMap<String, Object>();

		// 插入产业经济体量分布数据
		List<Map<String, Object>> cyjjtlfbList = new ArrayList<Map<String, Object>>();
		tempMap.put("name", "产业A");
		tempMap.put("num", 79);
		cyjjtlfbList.add(tempMap);
		tempMap = new HashMap<String, Object>();

		tempMap.put("name", "产业B");
		tempMap.put("num", 37);
		cyjjtlfbList.add(tempMap);
		tempMap = new HashMap<String, Object>();

		tempMap.put("name", "产业C");
		tempMap.put("num", 46);
		cyjjtlfbList.add(tempMap);
		tempMap = new HashMap<String, Object>();

		resultMap.put("cyfbList", cyfbList);
		resultMap.put("cyjjtlfbList", cyjjtlfbList);

		return resultMap;
	}

	@Override
	@Cacheable(key = "methodName")
	public Map<String, Object> queryEnterpriseGenebook() {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();

		Map<String, Object> tempMap = new HashMap<String, Object>();
		tempMap.put("name", "宝塔区");
		List<Map<String,Object>> list2 = new ArrayList<Map<String,Object>>();
		Map<String, Object> tempMap2 = new HashMap<String, Object>();
		tempMap2.put("num", 20);
		tempMap2.put("name", "电商");
		list2.add(tempMap2);
		tempMap2 = new HashMap<String, Object>();
		tempMap2.put("num", 20);
		tempMap2.put("name", "餐饮");
		list2.add(tempMap2);
		tempMap2 = new HashMap<String, Object>();
		tempMap2.put("num", 20);
		tempMap2.put("name", "纺织");
		list2.add(tempMap2);
		tempMap2 = new HashMap<String, Object>();
		tempMap2.put("num", 20);
		tempMap2.put("name", "种植");
		list2.add(tempMap2);
		tempMap2 = new HashMap<String, Object>();
		tempMap2.put("num", 20);
		tempMap2.put("name", "养殖");
		list2.add(tempMap2);
		tempMap.put("dimension", list2);
		
		for (int i = 0; i < 12; i++) {
			list.add(tempMap);
		}
		resultMap.put("resultList", list);

		return resultMap;
	}

	@Override
	@Cacheable(key = "methodName")
	public List<Map<String, Object>> queryFinancialInformation() {
		Map<String, Object> resultMap = new HashMap<String, Object>();

		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		Map<String, Object> tempMap = new HashMap<String, Object>();
		
		List<Map<String, Object>> list2 = new ArrayList<Map<String, Object>>();
		
		tempMap.put("name", "资产总额");
		tempMap.put("num",43);
		list2.add(tempMap);
		tempMap = new HashMap<String, Object>();

		tempMap.put("name", "负债总额");
		tempMap.put("num",36);
		list2.add(tempMap);
		tempMap = new HashMap<String, Object>();
		
		tempMap.put("name", "所有者权益");
		tempMap.put("num",27);
		list2.add(tempMap);
		tempMap = new HashMap<String, Object>();
		
		tempMap.put("name", "营业收入");
		tempMap.put("num",15);
		list2.add(tempMap);
		tempMap = new HashMap<String, Object>();
		
		tempMap.put("name", "容利润总额");
		tempMap.put("num",11);
		list2.add(tempMap);
		tempMap = new HashMap<String, Object>();
		
		tempMap.put("name", "净利润");
		tempMap.put("num",4);
		list2.add(tempMap);
		tempMap = new HashMap<String, Object>();
		

		for (int i = 0; i < 6; i++) {
			resultMap.put("year", String.valueOf(2014 + i));
			resultMap.put("data",list2);
			list.add(resultMap);
		}

		return list;
	}

	@Override
	@Cacheable(key = "methodName")
	public List<Map<String, Object>> queryDistrictCreditRating() {

		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		String[] name = { "子长县", "宜川县", "甘泉县", "黄龙县", "安塞县", "洛川县", "富县", "延长县", "黄陵县", "延川县", "吴起县", "宝塔区", "志丹县" };
		int[] num = { 3, 12, 24, 29, 31, 32, 50, 51, 59, 96, 136, 196, 216 };

		Map<String, Object> tempMap = new HashMap<String, Object>();
		for (int i = 0; i < name.length; i++) {
			tempMap.put("name", name[i]);
			tempMap.put("num", num[i]);
			list.add(tempMap);
			tempMap = new HashMap<String, Object>();
		}
		

		return list;
	}

	@Override
	@Cacheable(key = "methodName")
	public Map<String, Object> queryALevelEnterprise() {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		List<String> list = new ArrayList<String>();

		String[] name = { "陕西鼎业征信有限公司", "陕西鼎业征信有限公司", "陕西农邦信息技术有限公司", "陕西农邦信息技术有限公司", "榆林市荣岩地质勘探有限公司横山县分公司",
				"榆林市荣岩地质勘探有限公司横山县分公司", "榆林市远达地质灾害综合治理有限责任公司", "榆林市远达地质灾害综合治理有限责任公司", "陕西新鑫地质矿业安全工程有限公司山阳分公司",
				"陕西新鑫地质矿业安全工程有限公司山阳分公司" };

		for (int i = 0; i < name.length; i++) {
			list.add(name[i]);
		}
		
		resultMap.put("resultList", list);
		resultMap.put("totalCount", list.size());
		
		return resultMap;
	}

	@Override
	@Cacheable(key = "methodName")
	public Map<String, Object> queryAlertList() {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		List<String> list = new ArrayList<String>();

		String[] name = { "陕西鼎业征信有限公司1", "陕西鼎业征信有限公司", "陕西农邦信息技术有限公司", "陕西农邦信息技术有限公司", "榆林市荣岩地质勘探有限公司横山县分公司",
				"榆林市荣岩地质勘探有限公司横山县分公司", "榆林市远达地质灾害综合治理有限责任公司", "榆林市远达地质灾害综合治理有限责任公司", "陕西新鑫地质矿业安全工程有限公司山阳分公司",
				"陕西新鑫地质矿业安全工程有限公司山阳分公司" };

		for (int i = 0; i < name.length; i++) {
			list.add(name[i]);
		}
		
		resultMap.put("resultList", list);
		resultMap.put("totalCount", list.size());
		
		return resultMap;
	}

}
